#ifndef SCT_RTSPSERVER_AACSOURCE_H
#define SCT_RTSPSERVER_AACSOURCE_H

#include "sct/core/common.h"
#include "sct/rtspserver/streamsource.h"

#include "FramedSource.hh"

namespace sct
{

class CAACSource: public FramedSource
{
public:
  static CAACSource* createNew(UsageEnvironment& env, void* audio);

  unsigned samplingFrequency() const { return fSamplingFrequency; }
  unsigned numChannels() const { return fNumChannels; }
  char const* configStr() const { return fConfigStr; }
      // returns the 'AudioSpecificConfig' for this stream (in ASCII form)

private:
  CAACSource(UsageEnvironment& env, CStreamSource * audio, u_int8_t profile,
		      u_int8_t samplingFrequencyIndex, u_int8_t channelConfiguration);
	// called only by createNew()

  virtual ~CAACSource();

private:
  // redefined virtual functions:
  virtual void doGetNextFrame();
  virtual void doStopGettingFrames();

private:
	static void tryToGetNextFrame(void* p);
private:
  unsigned fSamplingFrequency;
  unsigned fNumChannels;
  unsigned fuSecsPerFrame;
  char fConfigStr[5];

  CStreamSource * mSource;
	double mStartReadTime;
	TaskToken mReadTask;
};

}//end namespace



#endif
